<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>cloud_07</title><link href='https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext' rel='stylesheet' type='text/css' /><style type='text/css'>html {overflow-x: initial !important;}:root { --node-fill: #ECECFF; --node-border: #CCCCFF; --cluster-fill: #ffffde; --cluster-border: #aaaa33; --note-fill: #fff5ad; --note-border: #aaaa33; --mermaid-color: var(--text-color); }


:root { --bg-color:#ffffff; --text-color:#333333; --select-text-bg-color:#B5D6FC; --select-text-font-color:auto; --monospace:"Lucida Console",Consolas,"Courier",monospace; --title-bar-height:20px; }
.mac-os-11 { --title-bar-height:28px; }
html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; tab-size: 4; }
iframe { margin: auto; }
a.url { word-break: break-all; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; overflow-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 36px; }
#write.first-line-indent p { text-indent: 2em; }
#write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; }
#write.first-line-indent li { margin-left: 2em; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; }
.typora-export .task-list-item input { pointer-events: none; }
@media screen and (max-width: 500px) {
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  #write { padding-left: 20px; padding-right: 20px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
#write li > figure:last-child { margin-bottom: 0.5rem; }
#write ol, #write ul { position: relative; }
img { max-width: 100%; vertical-align: middle; image-orientation: from-image; }
button, input, select, textarea { color: inherit; font: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
*, ::after, ::before { box-sizing: border-box; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; }
#write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; }
p { line-height: inherit; }
h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 4; }
p { orphans: 4; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
.md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; }
a { cursor: pointer; }
sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-radius: 4px; cursor: pointer; }
sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; }
figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; }
figure > table { margin: 0px; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 32px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror-linenumber { user-select: none; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
#write pre { white-space: pre-wrap; }
#write.fences-no-line-wrapping pre { white-space: pre; }
#write pre.ty-contain-cm { white-space: normal; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
#write .md-fences.mock-cm { white-space: pre-wrap; }
.md-fences.md-fences-with-lineno { padding-left: 0px; }
#write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; }
.md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; }
.CodeMirror-line, twitterwidget { break-inside: avoid; }
.footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; }
.footnotes + .footnotes { margin-top: 0px; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: 0px 0px; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li .mathjax-block, li p { margin: 0.5rem 0px; }
li blockquote { margin: 1rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child, li > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; }
#write .footnote-line { white-space: pre-wrap; }
@media print {
  body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; font-variant-ligatures: no-common-ligatures; }
  #write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  .typora-export #write { break-after: avoid; }
  .typora-export #write::after { height: 0px; }
  .is-mac table { break-inside: avoid; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; }
#write.first-line-indent p > .md-image:only-child:not(.md-img-error) img { left: -2em; position: relative; }
p > .md-image:only-child { display: inline-block; width: 100%; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.md-math-block { width: 100%; }
.md-math-block:not(:empty)::after { display: none; }
.MathJax_ref { fill: currentcolor; }
[contenteditable="true"]:active, [contenteditable="true"]:focus, [contenteditable="false"]:active, [contenteditable="false"]:focus { outline: 0px; box-shadow: none; }
.md-task-list-item { position: relative; list-style-type: none; }
.task-list-item.md-task-list-item { padding-left: 0px; }
.md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc-content::after, .md-toc::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); }
.md-toc-item a { text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) {
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
code, pre, samp, tt { font-family: var(--monospace); }
kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); }
code { text-align: left; vertical-align: initial; }
a.md-print-anchor { white-space: pre !important; border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; background: 0px 0px !important; text-decoration: initial !important; text-shadow: initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.html-for-mac .inline-math-svg .MathJax_SVG { vertical-align: 0.2px; }
.md-math-block .MathJax_SVG_Display { text-align: center; margin: 0px; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; overflow-y: hidden; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: var(--monospace); }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: 400; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none 0s ease 0s; }
.MathJax_SVG_Display svg { vertical-align: middle !important; margin-bottom: 0px !important; margin-top: 0px !important; }
.os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; }
.md-diagram-panel > svg { max-width: 100%; }
[lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; height: auto; }
[lang="mermaid"] .node text { font-size: 1rem; }
table tr th { border-bottom: 0px; }
video { max-width: 100%; display: block; margin: 0px auto; }
iframe { max-width: 100%; width: 100%; border: none; }
.highlight td, .highlight tr { border: 0px; }
mark { background: rgb(255, 255, 0); color: rgb(0, 0, 0); }
.md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; }
mark .md-meta { color: rgb(0, 0, 0); opacity: 0.3 !important; }
@media print {
  .typora-export h1, .typora-export h2, .typora-export h3, .typora-export h4, .typora-export h5, .typora-export h6 { break-inside: avoid; }
}
.md-diagram-panel .messageText { stroke: none !important; }
.md-diagram-panel .start-state { fill: var(--node-fill); }
.md-diagram-panel .edgeLabel rect { opacity: 1 !important; }
.md-require-zoom-fix foreignobject { font-size: var(--mermaid-font-zoom); }


.CodeMirror { height: auto; }
.CodeMirror.cm-s-inner { background: inherit; }
.CodeMirror-scroll { overflow: auto hidden; z-index: 3; }
.CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background: inherit; white-space: nowrap; }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: rgb(0, 0, 0); }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-property { color: rgb(0, 0, 0); }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: 700; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: red; }
.cm-invalidchar { color: red; }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background: inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background: inherit; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: hidden; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-wrapper { position: absolute; z-index: 4; background: 0px 0px !important; border: none !important; }
.CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; background: 0px 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; overflow-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }
.CodeMirror-wrap pre { overflow-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
@media print {
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}


:root {
    --side-bar-bg-color: #fafafa;
    --control-text-color: #777;
}

@include-when-export url(https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);

/* open-sans-regular - latin-ext_latin */
  /* open-sans-italic - latin-ext_latin */
    /* open-sans-700 - latin-ext_latin */
    /* open-sans-700italic - latin-ext_latin */
  html {
    font-size: 16px;
}

body {
    font-family: "Open Sans","Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: rgb(51, 51, 51);
    line-height: 1.6;
}

#write {
    max-width: 860px;
  	margin: 0 auto;
  	padding: 30px;
    padding-bottom: 100px;
}

@media only screen and (min-width: 1400px) {
	#write {
		max-width: 1024px;
	}
}

@media only screen and (min-width: 1800px) {
	#write {
		max-width: 1200px;
	}
}

#write > ul:first-child,
#write > ol:first-child{
    margin-top: 30px;
}

a {
    color: #4183C4;
}
h1,
h2,
h3,
h4,
h5,
h6 {
    position: relative;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-weight: bold;
    line-height: 1.4;
    cursor: text;
}
h1:hover a.anchor,
h2:hover a.anchor,
h3:hover a.anchor,
h4:hover a.anchor,
h5:hover a.anchor,
h6:hover a.anchor {
    text-decoration: none;
}
h1 tt,
h1 code {
    font-size: inherit;
}
h2 tt,
h2 code {
    font-size: inherit;
}
h3 tt,
h3 code {
    font-size: inherit;
}
h4 tt,
h4 code {
    font-size: inherit;
}
h5 tt,
h5 code {
    font-size: inherit;
}
h6 tt,
h6 code {
    font-size: inherit;
}
h1 {
    font-size: 2.25em;
    line-height: 1.2;
    border-bottom: 1px solid #eee;
}
h2 {
    font-size: 1.75em;
    line-height: 1.225;
    border-bottom: 1px solid #eee;
}

/*@media print {
    .typora-export h1,
    .typora-export h2 {
        border-bottom: none;
        padding-bottom: initial;
    }

    .typora-export h1::after,
    .typora-export h2::after {
        content: "";
        display: block;
        height: 100px;
        margin-top: -96px;
        border-top: 1px solid #eee;
    }
}*/

h3 {
    font-size: 1.5em;
    line-height: 1.43;
}
h4 {
    font-size: 1.25em;
}
h5 {
    font-size: 1em;
}
h6 {
   font-size: 1em;
    color: #777;
}
p,
blockquote,
ul,
ol,
dl,
table{
    margin: 0.8em 0;
}
li>ol,
li>ul {
    margin: 0 0;
}
hr {
    height: 2px;
    padding: 0;
    margin: 16px 0;
    background-color: #e7e7e7;
    border: 0 none;
    overflow: hidden;
    box-sizing: content-box;
}

li p.first {
    display: inline-block;
}
ul,
ol {
    padding-left: 30px;
}
ul:first-child,
ol:first-child {
    margin-top: 0;
}
ul:last-child,
ol:last-child {
    margin-bottom: 0;
}
blockquote {
    border-left: 4px solid #dfe2e5;
    padding: 0 15px;
    color: #777777;
}
blockquote blockquote {
    padding-right: 0;
}
table {
    padding: 0;
    word-break: initial;
}
table tr {
    border-top: 1px solid #dfe2e5;
    margin: 0;
    padding: 0;
}
table tr:nth-child(2n),
thead {
    background-color: #f8f8f8;
}
table th {
    font-weight: bold;
    border: 1px solid #dfe2e5;
    border-bottom: 0;
    margin: 0;
    padding: 6px 13px;
}
table td {
    border: 1px solid #dfe2e5;
    margin: 0;
    padding: 6px 13px;
}
table th:first-child,
table td:first-child {
    margin-top: 0;
}
table th:last-child,
table td:last-child {
    margin-bottom: 0;
}

.CodeMirror-lines {
    padding-left: 4px;
}

.code-tooltip {
    box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
    border-top: 1px solid #eef2f2;
}

.md-fences,
code,
tt {
    border: 1px solid #e7eaed;
    background-color: #f8f8f8;
    border-radius: 3px;
    padding: 0;
    padding: 2px 4px 0px 4px;
    font-size: 0.9em;
}

code {
    background-color: #f3f4f4;
    padding: 0 2px 0 2px;
}

.md-fences {
    margin-bottom: 15px;
    margin-top: 15px;
    padding-top: 8px;
    padding-bottom: 6px;
}


.md-task-list-item > input {
  margin-left: -1.3em;
}

@media print {
    html {
        font-size: 13px;
    }
    table,
    pre {
        page-break-inside: avoid;
    }
    pre {
        word-wrap: break-word;
    }
}

.md-fences {
	background-color: #f8f8f8;
}
#write pre.md-meta-block {
	padding: 1rem;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f7f7f7;
    border: 0;
    border-radius: 3px;
    color: #777777;
    margin-top: 0 !important;
}

.mathjax-block>.code-tooltip {
	bottom: .375rem;
}

.md-mathjax-midline {
    background: #fafafa;
}

#write>h3.md-focus:before{
	left: -1.5625rem;
	top: .375rem;
}
#write>h4.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
#write>h5.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
#write>h6.md-focus:before{
	left: -1.5625rem;
	top: .285714286rem;
}
.md-image>.md-meta {
    /*border: 1px solid #ddd;*/
    border-radius: 3px;
    padding: 2px 0px 0px 4px;
    font-size: 0.9em;
    color: inherit;
}

.md-tag {
    color: #a7a7a7;
    opacity: 1;
}

.md-toc { 
    margin-top:20px;
    padding-bottom:20px;
}

.sidebar-tabs {
    border-bottom: none;
}

#typora-quick-open {
    border: 1px solid #ddd;
    background-color: #f8f8f8;
}

#typora-quick-open-item {
    background-color: #FAFAFA;
    border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee;
    border-style: solid;
    border-width: 1px;
}

/** focus mode */
.on-focus-mode blockquote {
    border-left-color: rgba(85, 85, 85, 0.12);
}

header, .context-menu, .megamenu-content, footer{
    font-family: "Segoe UI", "Arial", sans-serif;
}

.file-node-content:hover .file-node-icon,
.file-node-content:hover .file-node-open-state{
    visibility: visible;
}

.mac-seamless-mode #typora-sidebar {
    background-color: #fafafa;
    background-color: var(--side-bar-bg-color);
}

.md-lang {
    color: #b4654d;
}

.html-for-mac .context-menu {
    --item-hover-bg-color: #E6F0FE;
}

#md-notification .btn {
    border: 0;
}

.dropdown-menu .divider {
    border-color: #e5e5e5;
}

.ty-preferences .window-content {
    background-color: #fafafa;
}

.ty-preferences .nav-group-item.active {
    color: white;
    background: #999;
}

 :root {--mermaid-font-zoom:1.44em ;} 
</style>
</head>
<body class='typora-export os-windows'>
<div id='write'  class=''><h1><a name="kubernetes" class="md-header-anchor"></a><span>kubernetes</span></h1><div class='md-toc' mdtype='toc'><p class="md-toc-content" role="list"><span role="listitem" class="md-toc-item md-toc-h1" data-ref="n0"><a class="md-toc-inner" href="#kubernetes">kubernetes</a></span><span role="listitem" class="md-toc-item md-toc-h2" data-ref="n3"><a class="md-toc-inner" href="#资源文件模板">资源文件模板</a></span><span role="listitem" class="md-toc-item md-toc-h2" data-ref="n6"><a class="md-toc-inner" href="#控制器">控制器</a></span><span role="listitem" class="md-toc-item md-toc-h3" data-ref="n7"><a class="md-toc-inner" href="#deployment">Deployment</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n8"><a class="md-toc-inner" href="#deploy-图例">Deploy 图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n10"><a class="md-toc-inner" href="#资源对象案例">资源对象案例</a></span><span role="listitem" class="md-toc-item md-toc-h3" data-ref="n14"><a class="md-toc-inner" href="#daemonset">DaemonSet</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n15"><a class="md-toc-inner" href="#ds图例">DS图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n17"><a class="md-toc-inner" href="#资源对象案例-n17">资源对象案例</a></span><span role="listitem" class="md-toc-item md-toc-h3" data-ref="n19"><a class="md-toc-inner" href="#jobcronjob">Job/CronJob</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n20"><a class="md-toc-inner" href="#job图例">Job图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n22"><a class="md-toc-inner" href="#资源对象案例-n22">资源对象案例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n24"><a class="md-toc-inner" href="#cj图例">CJ图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n26"><a class="md-toc-inner" href="#资源对象案例-n26">资源对象案例</a></span><span role="listitem" class="md-toc-item md-toc-h3" data-ref="n28"><a class="md-toc-inner" href="#statefulset">StatefulSet</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n29"><a class="md-toc-inner" href="#sts图例">STS图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n31"><a class="md-toc-inner" href="#资源对象案例-n31">资源对象案例</a></span><span role="listitem" class="md-toc-item md-toc-h3" data-ref="n33"><a class="md-toc-inner" href="#horizontalpodautoscaling">HorizontalPodAutoscaling</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n34"><a class="md-toc-inner" href="#hpa图例">HPA图例</a></span><span role="listitem" class="md-toc-item md-toc-h4" data-ref="n36"><a class="md-toc-inner" href="#资源对象案例-n36">资源对象案例</a></span></p></div><h2><a name="资源文件模板" class="md-header-anchor"></a><span>资源文件模板</span></h2><p><span>如何获取资源对象模板</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><span><span>​</span>x</span></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># Pod 模板</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">--dry-run</span><span class="cm-operator">=</span>client表示模拟运行，但不实际执行操作或修改资源</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl run mypod --image=registry:5000/myos:httpd --dry-run=client -o yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Pod</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  creationTimestamp: null</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  labels:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  run: mypod</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: mypod</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  containers:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-attribute">-</span> image: myos:httpd</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  name: mypod</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  resources: {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  dnsPolicy: ClusterFirst</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  restartPolicy: Always</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">status: {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 查看帮助信息</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl explain pod.spec.restartPolicy</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">KIND: &nbsp; &nbsp; Pod</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">VERSION:  v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">FIELD: &nbsp;  restartPolicy &lt;string&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">DESCRIPTION:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; Restart policy <span class="cm-keyword">for</span> all containers within the pod. </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; One of Always, OnFailure, Never. Default to Always. More info:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/<span class="cm-comment">#restart-policy</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#service模板</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl create service clusterip --help<span class="cm-tab" role="presentation" cm-text="	">    </span>#查看帮助</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl create service clusterip my-cs --tcp=5678:8080 --dry-run=client -o yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Service</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  creationTimestamp: null</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  labels:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  app: my-cs</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: my-cs</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-attribute">-</span> name: <span class="cm-number">5678</span><span class="cm-attribute">-8080</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  port: <span class="cm-number">5678</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  targetPort: <span class="cm-number">8080</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  app: my-cs</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  type: ClusterIP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">status:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  loadBalancer: {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#namspace名称空间模板</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl create namespace --help</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># &nbsp; kubectl create namespace my-namespace --dry-run=client -o yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Namespace</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  creationTimestamp: null</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: my-namespace</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec: {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">status: {}</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 以下资源对象都可以用模板生成</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl create &lt;tab&gt;&lt;tab&gt;</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">clusterrole &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deployment &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; poddisruptionbudget &nbsp; &nbsp; &nbsp;  rolebinding</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">clusterrolebinding &nbsp; &nbsp;  ingress &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  priorityclass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  secret</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">configmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; job &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  quota &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-builtin">service</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">cronjob &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; namespace &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  role &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; serviceaccount</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1650px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1650px;"></div></div></div></pre><h2><a name="控制器" class="md-header-anchor"></a><span>控制器</span></h2><h3><a name="deployment" class="md-header-anchor"></a><span>Deployment</span></h3><h4><a name="deploy-图例" class="md-header-anchor"></a><span>Deploy 图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart0" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="314.11993408203125" style="max-width: 238.018px; height: 354.12px;" viewBox="0 0 238.0175018310547 314.11993408203125" class="md-require-zoom-fix"><style>#mermaidChart0{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart0 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart0 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart0 .edge-thickness-normal{stroke-width:2px;}#mermaidChart0 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart0 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart0 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart0 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart0 .marker{fill:#000000;}#mermaidChart0 .marker.cross{stroke:#000000;}#mermaidChart0 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart0 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart0 .label text{fill:#333;}#mermaidChart0 .node rect,#mermaidChart0 .node circle,#mermaidChart0 .node ellipse,#mermaidChart0 .node polygon,#mermaidChart0 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart0 .node .label{text-align:center;}#mermaidChart0 .node.clickable{cursor:pointer;}#mermaidChart0 .arrowheadPath{fill:undefined;}#mermaidChart0 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart0 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart0 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart0 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart0 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart0 .cluster text{fill:rgb(0,0,0);}#mermaidChart0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart0:root{--mermaid-font-family:sans-serif;}#mermaidChart0:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart0 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart0 .Pod tspan{fill:#000000 !important;}#mermaidChart0 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart0 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart0 flowchart-v2{fill:apa;}</style><g transform="translate(0, -0.000003814697265625)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"></g><g class="edgePaths"><path d="M119.00875091552734,108.74749755859375L119.00875091552734,112.91416422526042C119.00875091552734,117.08083089192708,119.00875091552734,125.41416422526042,119.00875091552734,133.74749755859375C119.00875091552734,142.0808308919271,119.00875091552734,150.4141642252604,119.00875091552734,154.5808308919271L119.00875091552734,158.74749755859375" id="L-D-R" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-D LE-R" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M79.00261172778363,198.22747802734375L70.55821815734899,202.3941446940104C62.11382458691435,206.5608113606771,45.225037446045064,214.8941446940104,36.78064387561042,223.22747802734375C28.33625030517578,231.5608113606771,28.33625030517578,239.8941446940104,28.33625030517578,244.0608113606771L28.33625030517578,248.22747802734375" id="L-R-P1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M119.00875091552734,198.22747802734375L119.00875091552734,202.3941446940104C119.00875091552734,206.5608113606771,119.00875091552734,214.8941446940104,119.00875091552734,223.22747802734375C119.00875091552734,231.5608113606771,119.00875091552734,239.8941446940104,119.00875091552734,244.0608113606771L119.00875091552734,248.22747802734375" id="L-R-P2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M159.01489010327106,198.22747802734375L167.4592836737057,202.3941446940104C175.90367724414034,206.5608113606771,192.7924643850096,214.8941446940104,201.23685795544426,223.22747802734375C209.6812515258789,231.5608113606771,209.6812515258789,239.8941446940104,209.6812515258789,244.0608113606771L209.6812515258789,248.22747802734375" id="L-R-P3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Deploy" id="flowchart-D-5" transform="translate(119.00875091552734, 58.373748779296875)"><circle rx="0" ry="0" r="50.373748779296875" width="100.74749755859375" height="39.47998046875"></circle><g class="label" style="" transform="translate(-42.873748779296875, -12.239990234375)"><foreignObject width="85.74749755859375" height="24.47998046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Deployment</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-R-6" transform="translate(119.00875091552734, 178.48748779296875)"><rect rx="19.739990234375" ry="19.739990234375" x="-49.77375030517578" y="-19.739990234375" width="99.54750061035156" height="39.47998046875"></rect><g class="label" style="" transform="translate(-37.33875274658203, -12.239990234375)"><foreignObject width="74.67750549316406" height="24.47998046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>ReplicaSet</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P1-7" label-offset-y="6.137485168104335" transform="translate(28.33625030517578, 277.17369651794434)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617465636854334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617465636854334" transform="translate(-20.33625030517578,-28.9462179865315)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.239990234375)"><foreignObject width="25.672500610351562" height="24.47998046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P2-8" label-offset-y="6.137485168104335" transform="translate(119.00875091552734, 277.17369651794434)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617465636854334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617465636854334" transform="translate(-20.33625030517578,-28.9462179865315)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.239990234375)"><foreignObject width="25.672500610351562" height="24.47998046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P3-9" label-offset-y="6.137485168104335" transform="translate(209.6812515258789, 277.17369651794434)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617465636854334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617465636854334" transform="translate(-20.33625030517578,-28.9462179865315)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.239990234375)"><foreignObject width="25.672500610351562" height="24.47998046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">创建deployment的资源对象文件</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># cd config/</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim mydeploy.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Deployment</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: apps/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myweb</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  replicas: <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#副本数量</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#标签选择器，管理含有哪个标签的pod</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  matchLabels:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  app: myhttp</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  template:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  labels: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#标签</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  app: myhttp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#名字</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  restartPolicy: Always</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  containers:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name: apache</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  image: registry:5000/myos:httpd</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  containerPort: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f mydeploy.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get deployments.apps</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp;  READY &nbsp; UP-TO-DATE &nbsp; AVAILABLE &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; <span class="cm-number">2</span>/2 &nbsp; &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 13s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get replicasets.apps</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DESIRED &nbsp; CURRENT &nbsp; READY &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; 17s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; &nbsp;  AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-2zvck &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 22s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-rc5hh &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 22s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#服务发布时，不会直接发布pod，而是pod前面加个service，创建服务访问集群</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim websvc.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Service</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: websvc</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  type: ClusterIP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  clusterIP: <span class="cm-number">10</span>.245.1.81</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  app: myhttp</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-attribute">-</span> protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  port: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  targetPort: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f websvc.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Welcome to The Apache.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 自维护自治理</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment">#  kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-2zvck &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m21s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-rc5hh &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m21s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># Pod 被删除后，Deployment 会自动创建新的 Pod 来维护集群的完整性</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete pod myweb-7d6b5866cb-2zvck </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment">#  kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-4q5rk &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  2s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb-rc5hh &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m36s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 动态更新集群副本数量</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl scale deployment myweb --replicas=6</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl scale deployment myweb --replicas=2</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">以上实现的这些功能自维护自治理，调整pod数量是replicaset做的，deployment创建了replicaset；使用deployment主要是因为replicaset有一个限制，它里面只能有一个pod模板，在生产环境，需要进行业务变更（更新，升级，迭代）时，有时需要调整模板，只能删了重写，但是不可避免会造成业务的中断，重写的内容页没有经过测试，部署应用很不方便，所以后面为了适应生产环境的要求，引进了deployment，可以创建多个replicaset，提供滚动更新的策略</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1879px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1879px;"></div></div></div></pre><p><span>历史版本、滚动更新（使用更多的资源，更新的速度更快）</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#查看滚动更新的状态，只有1版本，但是没有注释信息，rollout history查看历史版本</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl rollout history deployment myweb</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">deployment.apps/myweb </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">REVISION  CHANGE-CAUSE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &lt;none&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 添加注释信息</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl annotate deployments.apps myweb kubernetes.io/change-cause="httpd.v1"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 修改镜像，滚动更新集群</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81  #现在的服务是apache</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Welcome to The Apache.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># sed  's,myos:httpd,myos:nginx,' mydeploy.yaml | kubectl apply -f -<span class="cm-tab" role="presentation" cm-text="	">    </span><span class="cm-tab" role="presentation" cm-text="	">    </span>#换成nginx</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 更新注释信息</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl annotate deployments.apps myweb kubernetes.io/change-cause="nginx.v1"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get replicasets.apps </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DESIRED &nbsp; CURRENT &nbsp; READY &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-7d6b5866cb &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; 48m</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-9bdd96c9b &nbsp; &nbsp;<span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; 58s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Nginx is running !</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 历史版本与回滚，rollout history查看历史版本</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl rollout history deployment myweb</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">deployment.apps/myweb </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">REVISION  CHANGE-CAUSE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; httpd.v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; nginx.v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#rollout undo使用哪个版本，这里使用第一个版本</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl rollout undo deployment myweb --to-revision=1</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl rollout history deployment myweb<span class="cm-tab" role="presentation" cm-text="	">  </span>#k8s中切换是使用过去的配置，不是回到过去</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">deployment.apps/myweb </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">REVISION  CHANGE-CAUSE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; nginx.v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; httpd.v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Welcome to The Apache.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除控制器方法1</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete deployments.apps myweb </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除控制器方法2</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete -f mydeploy.yaml</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1123px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1123px;"></div></div></div></pre><h3><a name="daemonset" class="md-header-anchor"></a><span>DaemonSet</span></h3><h4><a name="ds图例" class="md-header-anchor"></a><span>DS图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart1" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="358.6858825683594" style="max-width: 384.404px; height: 398.686px;" viewBox="0 0 384.4039306640625 358.6858825683594" class="md-require-zoom-fix"><style>#mermaidChart1{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart1 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart1 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart1 .edge-thickness-normal{stroke-width:2px;}#mermaidChart1 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart1 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart1 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart1 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart1 .marker{fill:#000000;}#mermaidChart1 .marker.cross{stroke:#000000;}#mermaidChart1 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart1 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart1 .label text{fill:#333;}#mermaidChart1 .node rect,#mermaidChart1 .node circle,#mermaidChart1 .node ellipse,#mermaidChart1 .node polygon,#mermaidChart1 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart1 .node .label{text-align:center;}#mermaidChart1 .node.clickable{cursor:pointer;}#mermaidChart1 .arrowheadPath{fill:undefined;}#mermaidChart1 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart1 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart1 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart1 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart1 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart1 .cluster text{fill:rgb(0,0,0);}#mermaidChart1 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart1:root{--mermaid-font-family:sans-serif;}#mermaidChart1:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart1 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart1 .Pod tspan{fill:#000000 !important;}#mermaidChart1 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart1 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart1 flowchart-v2{fill:apa;}</style><g transform="translate(0, 0)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"></g><g class="edgePaths"><path d="M53.233985900878906,243.29298400878906L53.15065256754557,247.3763173421224C53.06731923421224,251.45965067545572,52.90065256754557,259.6263173421224,52.81731923421224,267.8763173421224C52.733985900878906,276.1263173421224,52.733985900878906,284.45965067545575,52.733985900878906,288.6263173421224L52.733985900878906,292.79298400878906" id="L-N1-P1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-N1 LE-P1" style="fill:none;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path><path d="M192.7019577026367,243.29298400878903L192.61862436930338,247.37631734212235C192.53529103597006,251.45965067545572,192.36862436930338,259.6263173421224,192.28529103597006,267.8763173421224C192.20195770263672,276.1263173421224,192.20195770263672,284.45965067545575,192.20195770263672,288.6263173421224L192.20195770263672,292.79298400878906" id="L-N2-P2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-N2 LE-P2" style="fill:none;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path><path d="M332.16992950439453,243.29298400878903L332.0865961710612,247.37631734212235C332.00326283772785,251.45965067545572,331.8365961710612,259.6263173421224,331.75326283772785,267.8763173421224C331.66992950439453,276.1263173421224,331.66992950439453,284.45965067545575,331.66992950439453,288.6263173421224L331.66992950439453,292.79298400878906" id="L-N3-P3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-N3 LE-P3" style="fill:none;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path><path d="M149.93225824957653,77.68492641136615L133.73254619146027,86.12494071064367C117.532834133344,94.56495500992118,85.13341001711144,111.44498360847622,69.01703129232851,124.13499790775374C52.90065256754557,136.82501220703125,53.06731923421224,145.32501220703125,53.15065256754557,149.57501220703125L53.233985900878906,153.82501220703125" id="L-Ds-N1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Ds LE-N1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M192.20195770263672,103.32501220703125L192.20195770263672,107.49167887369792C192.20195770263672,111.65834554036458,192.20195770263672,119.99167887369792,192.28529103597006,128.4083455403646C192.36862436930338,136.82501220703125,192.53529103597006,145.32501220703125,192.61862436930335,149.57501220703125L192.7019577026367,153.82501220703125" id="L-Ds-N2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Ds LE-N2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M234.4716571556969,77.68492641136615L250.67136921381316,86.12494071064367C266.8710812719294,94.56495500992118,299.270505388162,111.44498360847622,315.5535507796116,124.13499790775374C331.8365961710612,136.82501220703125,332.00326283772785,145.32501220703125,332.0865961710612,149.57501220703125L332.16992950439453,153.82501220703125" id="L-Ds-N3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Ds LE-N3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Pod" id="flowchart-N1-20" transform="translate(52.733985900878906, 198.05899810791016)"><polygon points="44.733985900878906,0 89.46797180175781,-44.733985900878906 44.733985900878906,-89.46797180175781 0,-44.733985900878906" class="label-container" transform="translate(-44.733985900878906,44.733985900878906)"></polygon><g class="label" style="" transform="translate(-17.493751525878906, -12.240234375)"><foreignObject width="34.98750305175781" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>node</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P1-21" label-offset-y="6.137485168104335" transform="translate(52.733985900878906, 321.739444732666)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-N2-22" transform="translate(192.20195770263672, 198.05899810791016)"><polygon points="44.733985900878906,0 89.46797180175781,-44.733985900878906 44.733985900878906,-89.46797180175781 0,-44.733985900878906" class="label-container" transform="translate(-44.733985900878906,44.733985900878906)"></polygon><g class="label" style="" transform="translate(-17.493751525878906, -12.240234375)"><foreignObject width="34.98750305175781" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>node</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P2-23" label-offset-y="6.137485168104335" transform="translate(192.20195770263672, 321.739444732666)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-N3-24" transform="translate(331.66992950439453, 198.05899810791016)"><polygon points="44.733985900878906,0 89.46797180175781,-44.733985900878906 44.733985900878906,-89.46797180175781 0,-44.733985900878906" class="label-container" transform="translate(-44.733985900878906,44.733985900878906)"></polygon><g class="label" style="" transform="translate(-17.493751525878906, -12.240234375)"><foreignObject width="34.98750305175781" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>node</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P3-25" label-offset-y="6.137485168104335" transform="translate(331.66992950439453, 321.739444732666)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Deploy" id="flowchart-Ds-26" transform="translate(192.20195770263672, 55.662506103515625)"><circle rx="0" ry="0" r="47.662506103515625" width="95.32501220703125" height="39.48046875"></circle><g class="label" style="" transform="translate(-40.162506103515625, -12.240234375)"><foreignObject width="80.32501220703125" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>DaemonSet</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例-n17" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># cp mydeploy.yaml myds.yaml</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim myds.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: DaemonSet &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#修改</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: apps/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#修改</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-comment">#replicas: 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #添加#号</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ......</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f myds.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods -o wide</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; AGE &nbsp; IP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  NODE &nbsp; &nbsp; &nbsp;  NOMINATED NODE &nbsp; READINESS GATES</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myds-c7hjn &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  6s &nbsp; &nbsp;<span class="cm-number">10</span>.244.3.53 &nbsp; node-0002 &nbsp; &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;none&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myds-rbmlv &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  6s &nbsp; &nbsp;<span class="cm-number">10</span>.244.2.35 &nbsp; node-0003 &nbsp; &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;none&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myds-v85tw &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  6s &nbsp; &nbsp;<span class="cm-number">10</span>.244.1.94 &nbsp; node-0001 &nbsp; &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;none&gt;</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除DS控制器</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete -f myds.yaml</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 550px;"></div><div class="CodeMirror-gutters" style="display: none; height: 550px;"></div></div></div></pre><h3><a name="jobcronjob" class="md-header-anchor"></a><span>Job/CronJob</span></h3><h4><a name="job图例" class="md-header-anchor"></a><span>Job图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart2" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="73.8929214477539" style="max-width: 166.545px; height: 113.893px;" viewBox="0 0 166.54522705078125 73.8929214477539" class="md-require-zoom-fix"><style>#mermaidChart2{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart2 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart2 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart2 .edge-thickness-normal{stroke-width:2px;}#mermaidChart2 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart2 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart2 .marker{fill:#000000;}#mermaidChart2 .marker.cross{stroke:#000000;}#mermaidChart2 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart2 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart2 .label text{fill:#333;}#mermaidChart2 .node rect,#mermaidChart2 .node circle,#mermaidChart2 .node ellipse,#mermaidChart2 .node polygon,#mermaidChart2 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart2 .node .label{text-align:center;}#mermaidChart2 .node.clickable{cursor:pointer;}#mermaidChart2 .arrowheadPath{fill:undefined;}#mermaidChart2 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart2 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart2 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart2 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart2 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart2 .cluster text{fill:rgb(0,0,0);}#mermaidChart2 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart2:root{--mermaid-font-family:sans-serif;}#mermaidChart2:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart2 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart2 .Pod tspan{fill:#000000 !important;}#mermaidChart2 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart2 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart2 flowchart-v2{fill:apa;}</style><g transform="translate(0, 0.0000019073486328125)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"></g><g class="edgePaths"><path d="M37.93636703491211,36.94646072387695L47.09242820739746,36.94646072387695C56.24848937988281,36.94646072387695,74.56061172485352,36.94646072387695,87.88333956400554,36.94646072387695C101.20606740315755,36.94646072387695,109.53940073649089,36.94646072387695,113.70606740315755,36.94646072387695L117.87273406982422,36.94646072387695" id="L-Job-P" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Job LE-P" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Deploy" id="flowchart-Job-32" transform="translate(37.93636703491211, 36.94646072387695)"><polygon points="9.8701171875,0 50.00261688232422,0 59.87273406982422,-19.740234375 50.00261688232422,-39.48046875 9.8701171875,-39.48046875 0,-19.740234375" class="label-container" transform="translate(-29.93636703491211,19.740234375)"></polygon><g class="label" style="" transform="translate(-12.56624984741211, -12.240234375)"><foreignObject width="25.13249969482422" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Job</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P-33" label-offset-y="6.137485168104335" transform="translate(138.208984375, 36.94646072387695)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例-n22" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim myjob.yaml</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Job</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: batch/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myjob</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  template:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  restartPolicy: OnFailure</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  containers:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name: myjob</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  image: registry:5000/myos:v2009</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  command: [<span class="cm-string">"/bin/sleep"</span>, <span class="cm-string">"10"</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f myjob.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get jobs.batch</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp;  COMPLETIONS &nbsp; DURATION &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myjob &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9s &nbsp; &nbsp; &nbsp; &nbsp; 9s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp; &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myjob--1-l65kb &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; Completed &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  14s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除Job控制器</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl delete -f myjob.yaml </span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 550px;"></div><div class="CodeMirror-gutters" style="display: none; height: 550px;"></div></div></div></pre><h4><a name="cj图例" class="md-header-anchor"></a><span>CJ图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart3" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="286.6258850097656" style="max-width: 295.618px; height: 326.626px;" viewBox="0 0 295.6181945800781 286.6258850097656" class="md-require-zoom-fix"><style>#mermaidChart3{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart3 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart3 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart3 .edge-thickness-normal{stroke-width:2px;}#mermaidChart3 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart3 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart3 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart3 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart3 .marker{fill:#000000;}#mermaidChart3 .marker.cross{stroke:#000000;}#mermaidChart3 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart3 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart3 .label text{fill:#333;}#mermaidChart3 .node rect,#mermaidChart3 .node circle,#mermaidChart3 .node ellipse,#mermaidChart3 .node polygon,#mermaidChart3 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart3 .node .label{text-align:center;}#mermaidChart3 .node.clickable{cursor:pointer;}#mermaidChart3 .arrowheadPath{fill:undefined;}#mermaidChart3 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart3 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart3 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart3 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart3 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart3 .cluster text{fill:rgb(0,0,0);}#mermaidChart3 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart3:root{--mermaid-font-family:sans-serif;}#mermaidChart3:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart3 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart3 .Pod tspan{fill:#000000 !important;}#mermaidChart3 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart3 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart3 flowchart-v2{fill:apa;}</style><g transform="translate(0, 0)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"></g><g class="edgePaths"><path d="M37.93636703491211,150.99273681640625L37.93636703491211,158.4494425455729C37.93636703491211,165.9061482747396,37.93636703491211,180.8195597330729,37.93636703491211,192.44293212890625C37.93636703491211,204.0663045247396,37.93636703491211,212.3996378580729,37.93636703491211,216.5663045247396L37.93636703491211,220.73297119140625" id="L-Job1-P1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Job1 LE-P1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M147.80910110473633,150.99273681640625L147.80910110473633,158.4494425455729C147.80910110473633,165.9061482747396,147.80910110473633,180.8195597330729,147.80910110473633,192.44293212890625C147.80910110473633,204.0663045247396,147.80910110473633,212.3996378580729,147.80910110473633,216.5663045247396L147.80910110473633,220.73297119140625" id="L-Job2-P2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Job2 LE-P2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M257.68183517456055,150.99273681640625L257.68183517456055,158.4494425455729C257.68183517456055,165.9061482747396,257.68183517456055,180.8195597330729,257.68183517456055,192.44293212890625C257.68183517456055,204.0663045247396,257.68183517456055,212.3996378580729,257.68183517456055,216.5663045247396L257.68183517456055,220.73297119140625" id="L-Job3-P3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-Job3 LE-P3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M115.86457106432503,62.543541165873904L102.87653705942289,69.8283680451293C89.88850305452074,77.11319492438469,63.912435044716425,91.68284868289545,50.92440103981426,106.42438129131752C37.93636703491211,121.16591389973958,37.93636703491211,136.0793253580729,37.93636703491211,143.5360310872396L37.93636703491211,150.99273681640625" id="L-CJob-Job1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-CJob LE-Job1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M147.80910110473633,81.25250244140625L147.80910110473633,85.41916910807292C147.80910110473633,89.58583577473958,147.80910110473633,97.91916910807292,147.80910110473633,109.54254150390625C147.80910110473633,121.16591389973958,147.80910110473633,136.0793253580729,147.80910110473633,143.5360310872396L147.80910110473633,150.99273681640625" id="L-CJob-Job2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-CJob LE-Job2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M179.7536311451476,62.543541165873904L192.74166515004978,69.8283680451293C205.72969915495193,77.11319492438469,231.70576716475625,91.68284868289545,244.6938011696584,106.42438129131752C257.68183517456055,121.16591389973958,257.68183517456055,136.0793253580729,257.68183517456055,143.5360310872396L257.68183517456055,150.99273681640625" id="L-CJob-Job3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-CJob LE-Job3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Pod" id="flowchart-Job1-44" transform="translate(37.93636703491211, 150.99273681640625)"><polygon points="9.8701171875,0 50.00261688232422,0 59.87273406982422,-19.740234375 50.00261688232422,-39.48046875 9.8701171875,-39.48046875 0,-19.740234375" class="label-container" transform="translate(-29.93636703491211,19.740234375)"></polygon><g class="label" style="" transform="translate(-12.56624984741211, -12.240234375)"><foreignObject width="25.13249969482422" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Job</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P1-45" label-offset-y="6.137485168104335" transform="translate(37.93636703491211, 249.6794319152832)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-Job2-46" transform="translate(147.80910110473633, 150.99273681640625)"><polygon points="9.8701171875,0 50.00261688232422,0 59.87273406982422,-19.740234375 50.00261688232422,-39.48046875 9.8701171875,-39.48046875 0,-19.740234375" class="label-container" transform="translate(-29.93636703491211,19.740234375)"></polygon><g class="label" style="" transform="translate(-12.56624984741211, -12.240234375)"><foreignObject width="25.13249969482422" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Job</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P2-47" label-offset-y="6.137485168104335" transform="translate(147.80910110473633, 249.6794319152832)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-Job3-48" transform="translate(257.68183517456055, 150.99273681640625)"><polygon points="9.8701171875,0 50.00261688232422,0 59.87273406982422,-19.740234375 50.00261688232422,-39.48046875 9.8701171875,-39.48046875 0,-19.740234375" class="label-container" transform="translate(-29.93636703491211,19.740234375)"></polygon><g class="label" style="" transform="translate(-12.56624984741211, -12.240234375)"><foreignObject width="25.13249969482422" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Job</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P3-49" label-offset-y="6.137485168104335" transform="translate(257.68183517456055, 249.6794319152832)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Deploy" id="flowchart-CJob-50" transform="translate(147.80910110473633, 44.626251220703125)"><circle rx="0" ry="0" r="36.626251220703125" width="73.25250244140625" height="39.48046875"></circle><g class="label" style="" transform="translate(-29.126251220703125, -12.240234375)"><foreignObject width="58.25250244140625" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>CronJob</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例-n26" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim mycj.yaml</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: CronJob</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: batch/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: mycronjob</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  schedule: <span class="cm-string">"*/1 * * * *"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  jobTemplate:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  template:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  restartPolicy: OnFailure</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  containers:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name: myjob</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  image: registry:5000/myos:v2009</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  command: [<span class="cm-string">"/bin/sleep"</span>, <span class="cm-string">"10"</span>]</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f mycj.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get cronjobs.batch</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp;  SCHEDULE &nbsp; &nbsp;  SUSPEND &nbsp; ACTIVE &nbsp; LAST SCHEDULE &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob &nbsp; */1 * * * * &nbsp; False &nbsp; &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp;  &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp;  9s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get jobs.batch</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COMPLETIONS &nbsp; DURATION &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob-28128544 &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10s &nbsp; &nbsp; &nbsp;  12s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  READY &nbsp; STATUS &nbsp; &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob-28128544--1-bzbnk &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; Completed &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  17s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 保留三次结果，多余的会被删除</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  READY &nbsp; STATUS &nbsp; &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob-28128544--1-bzbnk &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; Completed &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m12s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob-28128545--1-rd2hd &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; Completed &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  72s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mycronjob-28128546--1-5xg5f &nbsp; <span class="cm-number">0</span>/1 &nbsp; &nbsp; Completed &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  12s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除CJ控制器</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete -f mycj.yaml</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 848px;"></div><div class="CodeMirror-gutters" style="display: none; height: 848px;"></div></div></div></pre><h3><a name="statefulset" class="md-header-anchor"></a><span>StatefulSet</span></h3><h4><a name="sts图例" class="md-header-anchor"></a><span>STS图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart4" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="289.67877197265625" style="max-width: 443.895px; height: 329.679px;" viewBox="0 0 443.89508056640625 289.67877197265625" class="md-require-zoom-fix"><style>#mermaidChart4{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart4 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart4 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart4 .edge-thickness-normal{stroke-width:2px;}#mermaidChart4 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart4 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart4 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart4 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart4 .marker{fill:#000000;}#mermaidChart4 .marker.cross{stroke:#000000;}#mermaidChart4 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart4 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart4 .label text{fill:#333;}#mermaidChart4 .node rect,#mermaidChart4 .node circle,#mermaidChart4 .node ellipse,#mermaidChart4 .node polygon,#mermaidChart4 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart4 .node .label{text-align:center;}#mermaidChart4 .node.clickable{cursor:pointer;}#mermaidChart4 .arrowheadPath{fill:undefined;}#mermaidChart4 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart4 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart4 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart4 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart4 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart4 .cluster text{fill:rgb(0,0,0);}#mermaidChart4 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart4:root{--mermaid-font-family:sans-serif;}#mermaidChart4:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart4 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart4 .Pod tspan{fill:#000000 !important;}#mermaidChart4 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart4 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart4 flowchart-v2{fill:apa;}</style><g transform="translate(0, 0.0000019073486328125)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"></g><g class="edgePaths"><path d="M87.59301926870016,103.41494379074805L95.352933385131,92.33686327960288C103.11284750156183,81.25878276845769,118.6326757344235,59.10262174616732,130.559256517521,48.024541235022134C142.4858373006185,36.94646072387695,150.8191706339518,36.94646072387695,159.15250396728516,36.94646072387695C167.4858373006185,36.94646072387695,175.8191706339518,36.94646072387695,184.15250396728516,36.94646072387695C192.4858373006185,36.94646072387695,200.8191706339518,36.94646072387695,204.9858373006185,36.94646072387695L209.15250396728516,36.94646072387695" id="L-S-P1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-S LE-P1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M109.15250015258789,144.83938217163086L113.31916745503743,144.83938217163086C117.48583475748698,144.83938217163086,125.81916936238606,144.83938217163086,134.1525033315023,144.83938217163086C142.4858373006185,144.83938217163086,150.8191706339518,144.83938217163086,159.15250396728516,144.83938217163086C167.4858373006185,144.83938217163086,175.8191706339518,144.83938217163086,184.15250396728516,144.83938217163086C192.4858373006185,144.83938217163086,200.8191706339518,144.83938217163086,204.9858373006185,144.83938217163086L209.15250396728516,144.83938217163086" id="L-S-P2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-S LE-P2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M87.59301926870016,186.26382055251366L95.352933385131,197.34190106365884C103.11284750156183,208.41998157480404,118.6326757344235,230.5761425970944,130.559256517521,241.65422310823956C142.4858373006185,252.73230361938477,150.8191706339518,252.73230361938477,159.15250396728516,252.73230361938477C167.4858373006185,252.73230361938477,175.8191706339518,252.73230361938477,184.15250396728516,252.73230361938477C192.4858373006185,252.73230361938477,200.8191706339518,252.73230361938477,204.9858373006185,252.73230361938477L209.15250396728516,252.73230361938477" id="L-S-P3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-S LE-P3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M249.82500457763672,36.94646072387695L253.99167124430338,36.94646072387695C258.15833791097003,36.94646072387695,266.4916712443034,36.94646072387695,274.8250045776367,36.94646072387695C283.15833791097003,36.94646072387695,291.4916712443034,36.94646072387695,299.8250045776367,36.94646072387695C308.15833791097003,36.94646072387695,316.4916712443034,36.94646072387695,329.9228831273511,51.6385752360026C343.35409501039885,66.33068974812825,361.883185443161,95.71491877237956,371.147730659542,110.4070332845052L380.41227587592306,125.09914779663086" id="L-P1-SVC" class=" edge-thickness-normal edge-pattern-dotted flowchart-link LS-P1 LE-SVC" style="fill:none;stroke-width:2px;stroke-dasharray:3;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path><path d="M249.82500457763672,144.83938217163086L253.99167124430338,144.83938217163086C258.15833791097003,144.83938217163086,266.4916712443034,144.83938217163086,274.8250045776367,144.83938217163086C283.15833791097003,144.83938217163086,291.4916712443034,144.83938217163086,299.8250045776367,144.83938217163086C308.15833791097003,144.83938217163086,316.4916712443034,144.83938217163086,324.8250045776367,144.83938217163086C333.15833791097003,144.83938217163086,341.4916712443034,144.83938217163086,345.65833791097003,144.83938217163086L349.8250045776367,144.83938217163086" id="L-P2-SVC" class=" edge-thickness-normal edge-pattern-dotted flowchart-link LS-P2 LE-SVC" style="fill:none;stroke-width:2px;stroke-dasharray:3;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path><path d="M249.82500457763672,252.73230361938477L253.99167124430338,252.73230361938477C258.15833791097003,252.73230361938477,266.4916712443034,252.73230361938477,274.8250045776367,252.73230361938477C283.15833791097003,252.73230361938477,291.4916712443034,252.73230361938477,299.8250045776367,252.73230361938477C308.15833791097003,252.73230361938477,316.4916712443034,252.73230361938477,329.9228831273511,238.04018910725912C343.35409501039885,223.34807459513345,361.883185443161,193.96384557088217,371.147730659542,179.2717310587565L380.41227587592306,164.57961654663086" id="L-P3-SVC" class=" edge-thickness-normal edge-pattern-dotted flowchart-link LS-P3 LE-SVC" style="fill:none;stroke-width:2px;stroke-dasharray:3;" marker-start="url(#flowchart-circleStart)" marker-end="url(#flowchart-circleEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Deploy" id="flowchart-S-59" transform="translate(58.57625198364258, 144.83938217163086)"><circle rx="0" ry="0" r="50.57624816894531" width="101.15249633789062" height="39.48046875"></circle><g class="label" style="" transform="translate(-43.07624816894531, -12.240234375)"><foreignObject width="86.15249633789062" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>StatusfulSet</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P1-60" label-offset-y="6.137485168104335" transform="translate(229.48875427246094, 36.94646072387695)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P2-61" label-offset-y="6.137485168104335" transform="translate(229.48875427246094, 144.83938217163086)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P3-62" label-offset-y="6.137485168104335" transform="translate(229.48875427246094, 252.73230361938477)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-SVC-63" transform="translate(392.8600616455078, 144.83938217163086)"><rect rx="19.740234375" ry="19.740234375" x="-43.035057067871094" y="-19.740234375" width="86.07011413574219" height="39.48046875"></rect><g class="label" style="" transform="translate(-30.599998474121094, -12.240234375)"><foreignObject width="61.19999694824219" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>headless</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例-n31" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">StatefulSet在创建之前要求有个无头服务，即没有ip的服务，之后StatefulSet在创建pod时，按照顺序创建pod，把第一个pod的ip在无头服务中注册，成功之后，再创建第一个pod，注册，以此类推</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 配置headless服务(无头服务，没有ip的服务)</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim mysvc.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Service</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: mysvc</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  type: ClusterIP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  clusterIP: None &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#改为None，ip为空</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  app: myhttp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#标签为myhttp</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-attribute">-</span> protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  port: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  targetPort: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete -f mysvc.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f mysvc.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get service</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; TYPE &nbsp; &nbsp; &nbsp;  CLUSTER-IP &nbsp;  EXTERNAL-IP &nbsp; PORT(S) &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kubernetes &nbsp; ClusterIP &nbsp; <span class="cm-number">10</span>.245.0.1 &nbsp;  &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">443</span>/TCP &nbsp; 12d</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mysvc &nbsp; &nbsp; &nbsp;  ClusterIP &nbsp; None &nbsp; &nbsp; &nbsp; &nbsp;  &lt;none&gt; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-number">80</span>/TCP &nbsp;  13s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 创建statefulset控制器</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># cp mydeploy.yaml mysts.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim mysts.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: StatefulSet &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#资源类型</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: apps/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myweb</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  serviceName: <span class="cm-string">"mysvc"</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#服务的名称,后期创建的pod在这里注册</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  replicas: <span class="cm-number">2</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ....</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f mysts.yaml</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" class="cm-tab-wrap-hack" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods<span class="cm-tab" role="presentation" cm-text="	">  </span>#可以看到不是并发创建，是一个一个创建</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp;  READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-0 &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  78s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-1 &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  77s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment">#解析成功</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># host mysvc.default.svc.cluster.local 10.245.0.10</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Using domain server:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Name: <span class="cm-number">10</span>.245.0.10</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Address: <span class="cm-number">10</span>.245.0.10<span class="cm-comment">#53</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Aliases: </span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mysvc.default.svc.cluster.local has address <span class="cm-number">10</span>.244.1.95</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">mysvc.default.svc.cluster.local has address <span class="cm-number">10</span>.244.3.59</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.244.1.95</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Welcome to The Apache.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 删除sts控制器，删除两个资源</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl delete -f mysts.yaml -f mysvc.yaml</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1306px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1306px;"></div></div></div></pre><h3><a name="horizontalpodautoscaling" class="md-header-anchor"></a><span>HorizontalPodAutoscaling</span></h3><h4><a name="hpa图例" class="md-header-anchor"></a><span>HPA图例</span></h4><div class="md-diagram-panel"><svg id="mermaidChart5" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="361.67877197265625" style="max-width: 657.315px; height: 401.679px;" viewBox="0 0 657.3152465820312 361.67877197265625" class="md-require-zoom-fix"><style>#mermaidChart5{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;fill:#333333;}#mermaidChart5 .error-icon{fill:hsl(60,100%,100%);}#mermaidChart5 .error-text{fill:rgb(0,0,0);stroke:rgb(0,0,0);}#mermaidChart5 .edge-thickness-normal{stroke-width:2px;}#mermaidChart5 .edge-thickness-thick{stroke-width:3.5px;}#mermaidChart5 .edge-pattern-solid{stroke-dasharray:0;}#mermaidChart5 .edge-pattern-dashed{stroke-dasharray:3;}#mermaidChart5 .edge-pattern-dotted{stroke-dasharray:2;}#mermaidChart5 .marker{fill:#000000;}#mermaidChart5 .marker.cross{stroke:#000000;}#mermaidChart5 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:11.111110669595242px;}#mermaidChart5 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaidChart5 .label text{fill:#333;}#mermaidChart5 .node rect,#mermaidChart5 .node circle,#mermaidChart5 .node ellipse,#mermaidChart5 .node polygon,#mermaidChart5 .node path{fill:#ECECFF;stroke:hsl(240,60%,86.2745098039%);stroke-width:1px;}#mermaidChart5 .node .label{text-align:center;}#mermaidChart5 .node.clickable{cursor:pointer;}#mermaidChart5 .arrowheadPath{fill:undefined;}#mermaidChart5 .edgePath .path{stroke:#000000;stroke-width:1.5px;}#mermaidChart5 .flowchart-link{stroke:#000000;fill:none;}#mermaidChart5 .edgeLabel{background-color:#f4f4f4;text-align:center;}#mermaidChart5 .edgeLabel rect{opacity:0.5;background-color:#f4f4f4;fill:#f4f4f4;}#mermaidChart5 .cluster rect{fill:hsl(60,100%,100%);stroke:hsl(60,60%,90%);stroke-width:1px;}#mermaidChart5 .cluster text{fill:rgb(0,0,0);}#mermaidChart5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(60,100%,100%);border:1px solid undefined;border-radius:2px;pointer-events:none;z-index:100;}#mermaidChart5:root{--mermaid-font-family:sans-serif;}#mermaidChart5:root{--mermaid-alt-font-family:sans-serif;}#mermaidChart5 .PodCluster &gt; *{fill:#ffffc0 !important;color:#ff00ff !important;stroke-width:4px !important;}#mermaidChart5 .PodCluster tspan{fill:#ff00ff !important;}#mermaidChart5 .Pod1 &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;}#mermaidChart5 .Pod1 tspan{fill:#000000 !important;}#mermaidChart5 .Pod &gt; *{fill:#ccffbb !important;color:#000000 !important;stroke-width:3px !important;stroke:#f06080 !important;stroke-dasharray:6 !important;3 !important;}#mermaidChart5 .Pod tspan{fill:#000000 !important;}#mermaidChart5 .Deploy &gt; *{fill:#40aff0 !important;color:#f0ff00 !important;stroke:#f06080 !important;stroke-width:3px !important;}#mermaidChart5 .Deploy tspan{fill:#f0ff00 !important;}#mermaidChart5 flowchart-v2{fill:apa;}</style><g transform="translate(0, 2)"><marker id="flowchart-pointEnd" class="marker flowchart" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-pointStart" class="marker flowchart" viewBox="0 0 10 10" refX="0" refY="5" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="12" orient="auto"><path d="M 0 5 L 10 10 L 10 0 z" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-circleEnd" class="marker flowchart" viewBox="0 0 10 10" refX="11" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-circleStart" class="marker flowchart" viewBox="0 0 10 10" refX="-1" refY="5" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><circle cx="5" cy="5" r="5" class="arrowMarkerPath" style="stroke-width: 1; stroke-dasharray: 1, 0;"></circle></marker><marker id="flowchart-crossEnd" class="marker cross flowchart" viewBox="0 0 11 11" refX="12" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><marker id="flowchart-crossStart" class="marker cross flowchart" viewBox="0 0 11 11" refX="-1" refY="5.2" markerUnits="userSpaceOnUse" markerWidth="11" markerHeight="11" orient="auto"><path d="M 1,1 l 9,9 M 10,1 l -9,9" class="arrowMarkerPath" style="stroke-width: 2; stroke-dasharray: 1, 0;"></path></marker><g class="root"><g class="clusters"><g class="cluster PodCluster PodCluster" id="C1"><rect rx="0" ry="0" x="409.09510803222656" y="8" width="240.22012329101562" height="343.6787643432617"></rect><g class="cluster-label" transform="translate(489.3801727294922, 6)"><foreignObject width="79.64999389648438" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod cluster</span></div></foreignObject></g></g></g><g class="edgePaths"><path d="M506.9515504401924,160.09914779663086L515.5667471523087,152.73144340515137C524.1819438644252,145.36373901367188,541.4123372886579,130.6283302307129,554.1942006674409,119.22168896678436C566.976064046224,107.81504770285581,575.3093973795573,99.73717395795772,579.476064046224,95.69823708550865L583.6427307128906,91.65930021305961" id="L-R-P1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M533.6427307128906,179.83938217163086L537.8093973795573,179.83938217163086C541.976064046224,179.83938217163086,550.3093973795573,179.83938217163086,558.6427307128906,179.83938217163086C566.976064046224,179.83938217163086,575.3093973795573,179.83938217163086,579.476064046224,179.83938217163086L583.6427307128906,179.83938217163086" id="L-R-P2" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P2" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M497.5496367093762,199.57961654663086L507.7318190432953,214.2717310587565C517.9140013772144,228.96384557088217,538.2783660450525,258.3480745951335,552.6272150456382,273.0401891072591C566.976064046224,287.73230361938477,575.3093973795573,287.73230361938477,579.476064046224,287.73230361938477L583.6427307128906,287.73230361938477" id="L-R-P3" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-R LE-P3" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M153.97774158090542,145.6331558227539L167.20605306302664,151.33419354756674C180.4343645451479,157.03523127237955,206.89098750939036,168.43730672200522,224.28596565817824,174.13834444681802C241.68094380696616,179.83938217163086,250.01427714029947,179.83938217163086,254.18094380696616,179.83938217163086L258.3476104736328,179.83938217163086" id="L-HPA-D" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-HPA LE-D" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M359.09510803222656,179.83938217163086L363.26177469889325,179.83938217163086C367.4284413655599,179.83938217163086,375.76177469889325,179.83938217163086,384.09510803222656,179.83938217163086C392.4284413655599,179.83938217163086,400.76177469889325,179.83938217163086,409.09510803222656,179.83938217163086C417.4284413655599,179.83938217163086,425.76177469889325,179.83938217163086,429.9284413655599,179.83938217163086L434.09510803222656,179.83938217163086" id="L-D-R" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-D LE-R" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path><path d="M145.6582080348911,106.1526870727539L160.27310844134806,98.45611095428467C174.88800884780503,90.75953483581543,204.1178096607189,75.36638259887695,231.295001530392,67.66980648040771C258.4721934000651,59.97323036193848,283.5967763264974,59.97323036193848,308.7213592529297,59.97323036193848C333.845942179362,59.97323036193848,358.97052510579425,59.97323036193848,375.69948323567706,59.97323036193848C392.4284413655599,59.97323036193848,400.76177469889325,59.97323036193848,404.9284413655599,59.97323036193848L409.09510803222656,59.97323036193848" id="L-HPA-C1" class=" edge-thickness-normal edge-pattern-solid flowchart-link LS-HPA LE-C1" style="fill:none;" marker-end="url(#flowchart-pointEnd)"></path></g><g class="edgeLabels"><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g><g class="edgeLabel"><g class="label" transform="translate(0, 0)"><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default Pod1" id="flowchart-P1-74" label-offset-y="6.137485168104335" transform="translate(603.9789810180664, 71.94646072387695)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P2-75" label-offset-y="6.137485168104335" transform="translate(603.9789810180664, 179.83938217163086)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod" id="flowchart-P3-76" label-offset-y="6.137485168104335" transform="translate(603.9789810180664, 287.73230361938477)"><path d="M 0,6.137485168104335 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 a 20.33625030517578,6.137485168104335 0,0,0 -40.67250061035156 0 l 0,45.617953918104334 a 20.33625030517578,6.137485168104335 0,0,0 40.67250061035156 0 l 0,-45.617953918104334" transform="translate(-20.33625030517578,-28.9464621271565)"></path><g class="label" style="" transform="translate(-12.836250305175781, -12.240234375)"><foreignObject width="25.672500610351562" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Pod</span></div></foreignObject></g></g><g class="node default Pod1" id="flowchart-R-73" transform="translate(483.8689193725586, 179.83938217163086)"><rect rx="19.740234375" ry="19.740234375" x="-49.77381134033203" y="-19.740234375" width="99.54762268066406" height="39.48046875"></rect><g class="label" style="" transform="translate(-37.33875274658203, -12.240234375)"><foreignObject width="74.67750549316406" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>ReplicaSet</span></div></foreignObject></g></g><g class="node default Deploy" id="flowchart-HPA-77" transform="translate(108.1738052368164, 125.8929214477539)"><rect rx="19.740234375" ry="19.740234375" x="-100.17381286621094" y="-19.740234375" width="200.34762573242188" height="39.48046875"></rect><g class="label" style="" transform="translate(-87.73875427246094, -12.240234375)"><foreignObject width="175.47750854492188" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>HorizontalPodAutoscaler</span></div></foreignObject></g></g><g class="node default Deploy" id="flowchart-D-80" transform="translate(308.7213592529297, 179.83938217163086)"><circle rx="0" ry="0" r="50.373748779296875" width="100.74749755859375" height="39.48046875"></circle><g class="label" style="" transform="translate(-42.873748779296875, -12.240234375)"><foreignObject width="85.74749755859375" height="24.48046875"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; white-space: nowrap;"><span>Deployment</span></div></foreignObject></g></g></g></g></g></svg></div><h4><a name="资源对象案例-n36" class="md-header-anchor"></a><span>资源对象案例</span></h4><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 为 Deploy 模板添加资源配额</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim mydeploy.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Deployment</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: apps/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myweb</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  replicas: <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#调整副本为1</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  matchLabels:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  app: myhttp</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  template:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  labels:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  app: myhttp</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  restartPolicy: Always</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp;  containers:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name: apache</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  image: myos:httpd</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-attribute">-</span> name:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  containerPort: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  resources: &nbsp; &nbsp;<span class="cm-comment">#必须指定资源最小配额，否则HPA控制器不检测</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp;  requests:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cpu: <span class="cm-string">"200m"</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f mydeploy.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim websvc.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: Service</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: websvc</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  type: ClusterIP</span></pre><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  clusterIP: <span class="cm-number">10</span>.245.1.81</span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  selector:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  app: myhttp</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  ports:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;<span class="cm-attribute">-</span> protocol: TCP</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  port: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  targetPort: <span class="cm-number">80</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f websvc.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get pods</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; READY &nbsp; STATUS &nbsp;  RESTARTS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb-5576dbf74f-xnqg8 &nbsp; <span class="cm-number">1</span>/1 &nbsp; &nbsp; Running &nbsp; <span class="cm-number">0</span> &nbsp; &nbsp; &nbsp; &nbsp;  85s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">Welcome to The Apache.</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 创建 HPA 控制器</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># vim myhpa.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-attribute">---</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">kind: HorizontalPodAutoscaler</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">apiVersion: autoscaling/v1</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">metadata:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  name: myweb</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">spec:</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  minReplicas: <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#pod最小副本数量</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  maxReplicas: <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#pod最大副本数量</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  scaleTargetRef: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#监控的资源对象</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  kind: Deployment &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#资源对象类型</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  apiVersion: apps/v1 &nbsp; &nbsp; <span class="cm-comment">#版本</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"> &nbsp;  name: myweb &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment">#资源对象名称</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">  targetCPUUtilizationPercentage: <span class="cm-number">50</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="cm-comment">#警戒值：根据CPU利用率计算，以百分比计算</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl apply -f myhpa.yaml </span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 刚刚创建 unknown 是正常现象，最多等待 300s 就可以正常获取数据</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># kubectl get hpa</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp;  REFERENCE &nbsp; &nbsp; &nbsp; &nbsp;  TARGETS &nbsp; MINPODS &nbsp; MAXPODS &nbsp; REPLICAS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">0</span>%/50% &nbsp; &nbsp;<span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp;  23s</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 1650px;"></div><div class="CodeMirror-gutters" style="display: none; height: 1650px;"></div></div></div></pre><p><span>扩容测试</span></p><pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded md-focus" lang="shell" style="break-inside: unset;"><div class="CodeMirror cm-s-inner CodeMirror-wrap CodeMirror-focused" lang="shell"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 91.6667px; left: 8.15972px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></textarea></div><div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div><div class="CodeMirror-gutter-filler" cm-not-content="true"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; margin-bottom: 0px; border-right-width: 0px; padding-right: 0px; padding-bottom: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines" role="presentation"><div role="presentation" style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre>x</pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code" role="presentation" style=""><div class="" style="position: relative;"><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 终端 1 访问提高负载</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master config]<span class="cm-comment"># curl 10.245.1.81/info.php?id=10000000</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span class="cm-comment"># 终端 2 监控 HPA 变化</span></span></pre><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><div class="CodeMirror-gutter-background CodeMirror-activeline-gutter" style="left: 0px; width: 0px;"></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">[root@master ~]<span class="cm-comment"># kubectl get hpa -w</span></span></pre></div><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">NAME &nbsp;  REFERENCE &nbsp; &nbsp; &nbsp; &nbsp;  TARGETS &nbsp; MINPODS &nbsp; MAXPODS &nbsp; REPLICAS &nbsp; AGE</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">0</span>%/50% &nbsp; &nbsp;<span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp;  102s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">8</span>%/50% &nbsp; &nbsp;<span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m15s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">107</span>%/50% &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m30s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">535</span>%/50% &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp;  2m45s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">151</span>%/50% &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp;  3m</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">100</span>%/50% &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp;  3m15s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">0</span>%/50% &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp;  3m30s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">0</span>%/50% &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp;  8m16s</span></pre><pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;">myweb &nbsp; Deployment/myweb &nbsp; <span class="cm-number">0</span>%/50% &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">3</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-number">1</span> &nbsp; &nbsp; &nbsp; &nbsp;  8m31s</span></pre></div></div></div></div></div><div style="position: absolute; height: 0px; width: 1px; border-bottom: 0px solid transparent; top: 344px;"></div><div class="CodeMirror-gutters" style="display: none; height: 344px;"></div></div></div></pre></div>
</body>
</html>